
#override("body")
<body class="white-bg">
<div class="row">
	<div class="form-group" id="uploadResult">
		<div style="width:800px;margin: 0 auto;">
			<div>
				<p id="swfContainer">本组件需要安装Flash Player后才可使用，请从
					<a href="http://www.adobe.com/go/getflashplayer">这里</a>下载安装。
				</p>
			</div>
		</div>
	</div>
</div>
</body>
#end

#override("js")
<script type="text/javascript" src="#springUrl('/static/plugins/fullAvatarEditor-2.3/scripts/swfobject.js')"></script>
<script type="text/javascript" src="#springUrl('/static/plugins/fullAvatarEditor-2.3/scripts/fullAvatarEditor.js')"></script>
<script type="text/javascript">
	swfobject.addDomLoadEvent(function () {
		var swf = new fullAvatarEditor("#springUrl('/static/plugins/fullAvatarEditor-2.3/fullAvatarEditor.swf')",
			"#springUrl('/static/plugins/fullAvatarEditor-2.3/expressInstall.swf')", "swfContainer", {
				id: "swf",
				upload_url: "#springUrl('/upload/file.html')",
				method: "post",
				avatar_field_names: 'avatar_100.jpg', 			// 设置上传的文件名称
				avatar_sizes: "100*100",
				src_upload: 0
			}, function (msg) {
				//console.log("===msg====" + JSON.stringify(msg));
				switch (msg.code) {
					case 3 :
						if (msg.type == 0) {
							alert("摄像头已准备就绪且用户已允许使用。");
						}
						else if (msg.type == 1) {
							alert("摄像头已准备就绪但用户未允许使用！");
						}
						else {
							alert("摄像头被占用！");
						}
						break;
					case 5 :
						if (msg.type == 0) {
							// 上传成功，返回结果:{"success":true,"url":"G:\\WorkPro\\Unitd\\BankPro_KF\\bank\\bank-web\\web-declare\\2017\\MGWFz5zkMBSimXQrdnMfJ8.jpg","msg":"upload success.","size":21658}
//							$("#uploadResult").html("上传成功，返回结果:" + JSON.stringify(msg.content));
							if("true" == msg.content.success) {
								layer.msg("上传成功!", {icon :1});
								window.location.href="/index.html";
							} else {
								layer.msg("上传失败!", {icon :2});
								window.location.reload();
							}
						}
						break;
				}
			}
		);
	});
</script>
#end
#extends("/common/base.html")